# This file is part of Laivsys. See doc/README_FOR_APP for license.
# $Id: laivs_controller.rb 57 2008-01-30 23:40:41Z sigve.indregard $

# LaivsController: CRUD operations for laivs
class LaivsController < ApplicationController
  layout 'admin'
  #before_filter :require_login

  # GET /laivs
  # GET /laivs.xml
  def index
    @laivs = Laiv.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @laivs }
    end
  end

  # GET /laivs/1
  # GET /laivs/1.xml
  def show
    @laiv = Laiv.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @laiv }
    end
  end

  # GET /laivs/new
  # GET /laivs/new.xml
  def new
    @laiv = Laiv.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @laiv }
    end
  end

  # GET /laivs/1/edit
  def edit
    @laiv = Laiv.find(params[:id])
  end

  # POST /laivs
  # POST /laivs.xml
  def create
    @laiv = Laiv.new(params[:laiv])

    respond_to do |format|
      if @laiv.save
        flash[:notice] = 'Laiv was successfully created.'
        format.html { redirect_to(@laiv) }
        format.xml  { render :xml => @laiv, :status => :created, :location => @laiv }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @laiv.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /laivs/1
  # PUT /laivs/1.xml
  def update
    @laiv = Laiv.find(params[:id])

    respond_to do |format|
      if @laiv.update_attributes(params[:laiv])
        flash[:notice] = 'Laiv was successfully updated.'
        format.html { redirect_to(@laiv) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @laiv.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /laivs/1
  # DELETE /laivs/1.xml
  def destroy
    @laiv = Laiv.find(params[:id])
    @laiv.destroy

    respond_to do |format|
      format.html { redirect_to(laivs_url) }
      format.xml  { head :ok }
    end
  end
end
